package tests;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import controlisolation.lifecyclefsm.LifeCycleFSM;
import controlisolation.lifecyclefsm.stateexecutor.StateWork;

import controlisolation.lifecyclefsm.stateexecutor.WorkFinishedEventListener;

import controlisolation.lifecyclefsm.stateexecutor.WorkStartedEventListener;


public class AbFSM implements 
        WorkStartedEventListener,
        WorkFinishedEventListener
{

     private String  _fsmSCXMLPath="c:/temp/abStateMachine.scxml";
     private LifeCycleFSM _lifeCycleFSM;
     
     public void init() throws Exception
    {
         
         File f=new File(_fsmSCXMLPath);
         if (!f.exists())
         {
             throw new FileNotFoundException(_fsmSCXMLPath);
         }
         
         URL url= f.toURI().toURL();
         
         _lifeCycleFSM=new LifeCycleFSM(url);
         _lifeCycleFSM.setWorkForState("theAState",new OutputAWork());
         _lifeCycleFSM.setWorkForState("theBState",new OutputBWork());
        
         _lifeCycleFSM.startRemoteDebugServer(9999);

         _lifeCycleFSM.bindTo(new AbStateMachineController());
         //_lifeCycleFSM.start();
         
    }

    
     public void start()
     {
        // _lifeCycleFSM.start();
     }


    @Override
    public void handleWorkStartedEvent(StateWork w) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void handleWorkFinishedEvent(StateWork w) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    
   
    

}
